package com.itheima.health.controller.mobile;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.result.PageResult;
import com.itheima.health.result.QueryPageBean;
import com.itheima.health.result.Result;
import com.itheima.health.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mobile/setmeal")
@Slf4j
public class UserSetmealController {

    @Autowired
    private SetmealService setmealService;

    /**
     * 分页查询
     * @return
     */
    @GetMapping("/getSetmeal")
    public Result getSetmeal(){
        List<Setmeal> setmealList = setmealService.getSetmeal();
        if(setmealList != null && setmealList.size() > 0){
            return new Result(true, MessageConst.ACTION_SUCCESS,setmealList);
        }
        return new Result(false, MessageConst.ACTION_SUCCESS);
    }

    @GetMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal = setmealService.findById(id);
        return new Result(true,MessageConst.ACTION_SUCCESS,setmeal);
    }
}
